import {
  http
} from 'http.js'

//登录验证码
function wxLogin(code, _data) {
  return http({
    url: 'api/login?type=2&js_code=' + code,
    //  + "&encrypt_data=" + encryptedData + "&iv=" + iv,
    data: _data
  })
}
//登录验证码
function getMsgCode(phoneNum) {
  return http({
    url: 'api/public/login/sms_code?phone=' + phoneNum,
  })
}

//换绑手机号的验证码
function getMsgCodeByChangePhone(phoneNum) {
  return http({
    url: 'api/public/login/sms_code?phone=' + phoneNum,
  })
}

function login(phoneNum, smsCode) {
  return http({
    url: 'api/login?shareToken=&type=20&phone_num=' + phoneNum + '&sms_code=' + smsCode,
    method: 'POST'
  })
}

function getUserInfo() {
  return http({
    url: '/api/seeker/personal_center'
  })
}

//换绑手机号
function changePhone(_data) {
  return http({
    url: 'api/basic/replace_phone_number',
    data: _data,
    method: 'POST'
  })
}

//获取面试列表
function getInterviewList(type, pageIndex, pageSize = 20) {
  let offset = (pageIndex - 1) * pageSize;
  return http({
    url: 'api/recruit_sign_up/list?offset=' + offset + "&limit=" + pageSize + "&status=" + type
  })
}

//获取面试详情
function getInterviewDetail(interviewId) {
  return http({
    url: 'api/recruit_sign_up/simple_detail?id=' + interviewId
  })
}

function getMyFavouriteList(_data) {
  return http({
    url: '/api/recruit/list',
    data: _data,
    method: "POST"
  })
}

//取消收藏
function deleteFromFavouriteList(_data) {
  return http({
    url: '/api/recruit/collect',
    data: _data,
    method: "POST"
  })
}

//获取工作岗位
function getJob() {
  return http({
    url: '/api/public/positions_for_recruit'
  })
}

module.exports = {
  wxLogin: wxLogin,
  getMsgCode: getMsgCode,
  login: login,
  getUserInfo: getUserInfo,
  getMsgCodeByChangePhone: getMsgCodeByChangePhone,
  changePhone: changePhone,
  getInterviewList: getInterviewList,
  getInterviewDetail: getInterviewDetail,
  getMyFavouriteList: getMyFavouriteList,
  deleteFromFavouriteList: deleteFromFavouriteList,
  getJob: getJob
}